Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development


Defining TreeView nodes

This section provides step-by-step instructions for working through the Department TreeView example. It also explains the elements of the dynamic TreeView. Figure 9–2 shows a picture of what you are building so you can better understand the following pieces as you create them:

Figure 9–2: Completed example TreeView

To build the descriptions and learn what they are for and how they relate:

  1. In the AppBuilder, select Build Tree Node Control, as shown:
  2. Choose Add to create your first tree node. (It doesn’t matter if something is currently selected, since you’re creating a top-level node.)

As shown in Figure 9–2, the three-level Department example requires you to define a total of five tree nodes. As you build a TreeView there is a node to represent the set of records at the next level down, and then another node to represent the individual records at that new node. So, you will define nodes for each of the following records:

Because each tree node defines both data at a certain level within the tree and also its relationship to the next level up, you must define a distinct node for each combination of a type of object or data that will be displayed at a level, and its relationship to the next level up. You will define a node for Departments with no parent relationship, because that will be the top of this TreeView. The Employee nodes will define themselves specifically as being for Employees of a Department, and the Family nodes as Family of an Employee. Other types of relationships for Employees or Family Members would require you to define new nodes.

Figure 9–3 shows an example of the Tree Node Maintenance frame.

Figure 9–3: Tree Node Maintenance frame

Continuing the Department example

To complete the Department example, you must define four more tree nodes, alternating data and text nodes. The next node down from Department is a text node that just displays the label Employees. It acts as a header for the individual Employee nodes of the selected Department.

To add the node:

  1. Save the Department node.
  2. Choose Add in the Tree Node Control window, then follow these steps:
    1. For the Node Code, type EmployeeTx (format is currently limited to ten characters).
    2. For the Parent Node Code, type Department, the node you defined earlier.
    3. For the Node Label, type Employees.
    4. For the Data Source Type, select Plain Text.
    5. For the text to be displayed next to the node, select Employees.
    6. The Primary SDO names the same SDO used by the level above, the one that will be providing key values to the next node down. For the Primary SDO, type departmefullo.
    7. This node will not launch a container window on the right side because it does not show individual record values. So, none of the remaining fields apply, except for the Image File Names, which would normally be the same choices as for any other node.

  3. Save this node, then choose Add again.
  4. Follow these steps to define the node for Employee records:
    1. For the Node code, type Employee.
    2. For the Parent Node Code, type EmployeeTx.
    3. For the Node Label, type Employee.
    4. For the Data Source Type, select SDO/SBO.
    5. For both the Data Source and Primary SDO, select employeefullo.
    6. For the Launch Container, select the name of the window defined for Employee maintenance, EmployeeFoldWin.
    7. To display the employee’s last name next to the node, type &1 for the Node Label Expression and Employee.LastName for the Label Text Substitution.
    8. Because this node uses the Department table as a parent, you list the Foreign Fields that define the foreign key relationship. Note that because the EmployeeTx text node is placed in between the Department data node and the Employee data node, that intervening EmployeeTx node repeats the name of the parent Data source. It is then the next node down, the Employee node, that actually defines the foreign key relationship between the parent and itself.

    9. For the Foreign Fields value, type Employee.DeptCode,DeptCode.
  5. Save this node, then choose Add again.
  6. Follow these steps to define another Text node that goes between Employee and Family:
    1. For the Node Code, type FamilyTxt.
    2. For the Parent Code, type Employee.
    3. For the Node Label and Plain Text, type Family Members.
    4. For the Data Source Type, select Plain text.
    5. For the Primary SDO, select employeefullo.
  7. Save this node, then choose Add again.
  8. Follow these steps to define the Family data node:
    1. For the Node Code, type Family.
    2. For the Parent Node Code, type FamilyTxt.
    3. For the Node Label, type Family Member.
    4. For the Data Source Type, select SDO/SBO.
    5. For the Data Source and Primary SDO, enter familyfullo.
    6. For the Launch Container, type FamilyFoldWin.
    7. For the Node Label Expression, type &1.
    8. For the Label Text Substitution, type Family.RelativeName to display the name of family member.
    9. For the Foreign Fields, type Family.EmpNum, EmpNum.
  9. Save each of the tree nodes in turn, then exit the Tree Node Control.

Once you have defined all the tree nodes needed by a TreeView window, you can define the window itself.

Note: These tree nodes define a particular hierarchy. Each node level defines its relationship to the next level above. Thus, to define a different TreeView window using some of the same tables, you must define a new set of tree nodes.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095